package com.leador.batch.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by lhy on 2016/6/14.
 */
public class DatabaseHelper extends SQLiteOpenHelper {
    private static final String DB_NAME = "mydata.db"; //数据库名称
    private static final int version = 1; //数据库版本
    public static final String DB_TABLE_NAME = "track";
    public DatabaseHelper(Context context) {
        super(context, DB_NAME, null, version);
    }

    /**
     * 创建数据库时调用
     * @param sqLiteDatabase
     */
    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        String sql = "create table "+DB_TABLE_NAME+" (id integer primary key autoincrement,loc_time varchar(100) not null , latitude varchar(100) not null" +
                ", longitude varchar(100) not null, speed varchar(100) , status varchar(100) ," +
                " ak varchar(100), service_id varchar(100), entity_name varchar(100)" +
                ", extend1 varchar(100), extend2 varchar(100) );";
        sqLiteDatabase.execSQL(sql);
    }

    /**
     * 版本更新时调用
     * @param sqLiteDatabase
     * @param i
     * @param i1
     */
    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

    }

}
